#include<bits/stdc++.h>
using namespace std;

int getBegin(string s) {
	for (int i = 0; i < s.size(); i++) {
		if (('0' <= s[i] && s[i] <= '9') || ('a' <= s[i] && s[i] <= 'c'))
			return i;
	}
	return 0;
}

string getInt(string s, int &begin) {
	string t;
	for (int i = begin; i < s.size(); i++) {
		if (!('0' <= s[i] && s[i] <= '9') && t.size() != 0) {
			begin = i + 1;
			return t;
		}
		t += s[i];
	}
	return t;
}

int main() {
	int n;
	cin >> n;
	getchar();
	char op = '+';
	while (n--) {
		string s;
		getline(cin, s);
		int begin = getBegin(s);
		if (s[0] >= 'a') {
			op = s[0];
			begin = 2;
		}

		string t1 = getInt(s, begin);
		string t2 = getInt(s, begin);

		int x = stoi(t1);
		int y = stoi(t2);

		cout << t1;

		int ans, len = 0;
		if (op == 'a') {
			cout << "+";
			ans = x + y;
		}
		if (op == 'b') {
			cout << "-";
			ans = x - y;
		}
		if (op == 'c') {
			cout << "*";
			ans = x * y;
		}

		len += t1.size() + t2.size() + 2 + to_string(ans).size();

		cout << t2 + "=" << ans << endl;
		cout << len;
		if (n)	cout << endl;
	}
	return 0;
}
